<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 可以通过hasOwnProperty来查看属性是否是私有的 -->
    <script>
        // this关键字添加的属性是私有属性
        function Person(name,age){
            this.name = name ,
            this.age = age
        }
        //原型里的属性是公有属性
        Person.prototype = {
            constructor:Person,
            sayName:function(){
                console.log(this.name);
            },
            sayAge(){
                console.log(this.age);
            }
        }
        var p = new Person("zz",18)
        console.log(p.hasOwnProperty("name"));
        console.log(p.hasOwnProperty("sayName"));
    </script>
</body>
</html>